﻿//////////////////////////////////////////// wellcome tree of life ///////////////////////////////////////////

//	These files are offered by The Wellcome Trust under the Creative Commons Licence: http://creativecommons.org/licenses/by-nc-nd/3.0/
//	Author: York Gibson - york@yorkgibson.co.uk, york@shadowindustries.co.uk
//	Version: 0.9
//	Date: 02/02/2009

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

package org.wellcometreeoflife.video {
	
	import flash.display.MovieClip;
	import fl.video.*
    import fl.video.FLVPlayback;
	import flash.events.*
	import flash.geom.ColorTransform
	import caurina.transitions.*
	import caurina.transitions.properties.ColorShortcuts
	import org.wellcometreeoflife.configuration.*
	import org.wellcometreeoflife.ui.*
	import playBtn;
	import pauseBtn;
	
	public class PlayPause extends UIButton {
		ColorShortcuts.init()
		public var pauseButton:pauseBtn;
		public var playButton:playBtn;
		private var flvPlaybackInstance:FLVPlayback
		private var videoContainer:MovieClip
		
		// Initialization:
		public function PlayPause() {
			configUI();
		}

		// Public Methods:
		
		public function set video(pInstance:MovieClip):void{
			videoContainer = pInstance;
		}
		
		public function get video():MovieClip{
			return videoContainer;
		}
		
		public function update():void{
			if(videoContainer.video.state == "playing"){
				pauseButton.visible = true
				playButton.visible = false
			} else {
				pauseButton.visible = false
				playButton.visible = true
			}
		}
		
		private function videoStateChange(event:Event):void{
			
		}
		private function pauseUpHandler(event:Event):void{
			videoContainer.video.pause()
		}
		private function playUpHandler(event:Event):void{
			scope.goVideo(event)
		}
		override protected function configUI():void {
			super.configUI()
			pauseButton.addEventListener(MouseEvent.MOUSE_UP, pauseUpHandler)
			playButton.addEventListener(MouseEvent.MOUSE_UP, playUpHandler)
			pauseButton.visible = false
			playButton.visible = false
		}
	}
	
}